﻿using AntDesign;
using IdentityServer4Blazor.Shared.Dto.BaseDto;
using IdentityServer4Blazor.Shared.Dto.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

namespace IdentityServer4Blazor.Client.ApiRequest
{
    public class UserReuqest:RequestBase
    {
        public string BaseUrl;
        public UserReuqest(HttpClient httpClient, MessageService messageService)
            :base(httpClient,messageService)
        {
            BaseUrl = "api/user";
        }
        public async Task<PageRequestOutput<UserListOutput>> GetUserList(int pageIndex,int pageSize)
        {
            var requestUrl = $"{BaseUrl}/GetUserList?pageIndex={pageIndex}&pageSize={pageSize}";
            var res = await GetAsync(requestUrl);
            if (res.Data != null)
            {
                return JsonSerializer.Deserialize<PageRequestOutput<UserListOutput>>(res.Data.ToString());
            }
            return new PageRequestOutput<UserListOutput>();
        }
    }
}
